package br.ufrj.dcc.org2.classification;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {
	public static void main(String[] args) throws IOException {
		
		FileLoader loader;
		OutputWriter output;
		int[] inputData;
		ArrayList<Integer> registro = new ArrayList<Integer>();
		int aKey, size, n, keysPerCell, separatorBitSize, bloomFilterSize;
		
		loader = new FileLoader();
		inputData = loader.getInputData();
		size = loader.getTableSize();
	
		// faz a tabela:
		HashTable theHashTable = new HashTable(size);
			
		for (int i=0;i<inputData.length;i+=4) { // insere os dados
			registro.clear();
			
			for(int j=0;j<4;j++)
				registro.add(inputData[i+j]);
			theHashTable.insere(registro);
		}
		System.out.println("estou aqui!!");
		
		while (true) { // interacoes com o usuario
			
			System.out.print("Digite o numero a ser buscado (-1 para sair): ");
			registro.set(0, getInt());
			if (registro.get(0) == -1) 
				break;
			else{
				for(int i=1;i<4;i++){
					System.out.print("Digite o valor campo "+i+" Caso o campo seja vazio digite -2: ");
					registro.set(i, getInt());
				}
				theHashTable.busca(registro);
				
			}
		}
		
		output = new OutputWriter(theHashTable);
	
	}

	public static String getString() throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String s = br.readLine();
		return s;
	}

	public static char getChar() throws IOException {
		String s = getString();
		return s.charAt(0);
	}

	public static int getInt() throws IOException {
		String s = getString();
		return Integer.parseInt(s);
	}
}
